package com.ruoyi.system.controller.car4s_controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.car4s_domain.Car4sCustomerPointsDetail;
import com.ruoyi.system.service.car4s_service.ICar4sCustomerPointsDetailService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 客户积分明细Controller
 * 
 * @author LK
 * @date 2024-06-29
 */
@RestController
@RequestMapping("/system/car_4s_customer_points_detail")
public class Car4sCustomerPointsDetailController extends BaseController
{
    @Autowired
    private ICar4sCustomerPointsDetailService car4sCustomerPointsDetailService;

    /**
     * 查询客户积分明细列表
     */
    @PreAuthorize("@ss.hasPermi('system:car_4s_customer_points_detail:list')")
    @GetMapping("/list")
    public TableDataInfo list(Car4sCustomerPointsDetail car4sCustomerPointsDetail)
    {
        startPage();
        List<Car4sCustomerPointsDetail> list = car4sCustomerPointsDetailService.selectCar4sCustomerPointsDetailList(car4sCustomerPointsDetail);
        return getDataTable(list);
    }

    /**
     * 导出客户积分明细列表
     */
    @PreAuthorize("@ss.hasPermi('system:car_4s_customer_points_detail:export')")
    @Log(title = "客户积分明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Car4sCustomerPointsDetail car4sCustomerPointsDetail)
    {
        List<Car4sCustomerPointsDetail> list = car4sCustomerPointsDetailService.selectCar4sCustomerPointsDetailList(car4sCustomerPointsDetail);
        ExcelUtil<Car4sCustomerPointsDetail> util = new ExcelUtil<Car4sCustomerPointsDetail>(Car4sCustomerPointsDetail.class);
        util.exportExcel(response, list, "客户积分明细数据");
    }

    /**
     * 获取客户积分明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:car_4s_customer_points_detail:query')")
    @GetMapping(value = "/{pointsId}")
    public AjaxResult getInfo(@PathVariable("pointsId") Long pointsId)
    {
        return success(car4sCustomerPointsDetailService.selectCar4sCustomerPointsDetailByPointsId(pointsId));
    }

    /**
     * 新增客户积分明细
     */
    @PreAuthorize("@ss.hasPermi('system:car_4s_customer_points_detail:add')")
    @Log(title = "客户积分明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Car4sCustomerPointsDetail car4sCustomerPointsDetail)
    {
        return toAjax(car4sCustomerPointsDetailService.insertCar4sCustomerPointsDetail(car4sCustomerPointsDetail));
    }

    /**
     * 修改客户积分明细
     */
    @PreAuthorize("@ss.hasPermi('system:car_4s_customer_points_detail:edit')")
    @Log(title = "客户积分明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Car4sCustomerPointsDetail car4sCustomerPointsDetail)
    {
        return toAjax(car4sCustomerPointsDetailService.updateCar4sCustomerPointsDetail(car4sCustomerPointsDetail));
    }

    /**
     * 删除客户积分明细
     */
    @PreAuthorize("@ss.hasPermi('system:car_4s_customer_points_detail:remove')")
    @Log(title = "客户积分明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{pointsIds}")
    public AjaxResult remove(@PathVariable Long[] pointsIds)
    {
        return toAjax(car4sCustomerPointsDetailService.deleteCar4sCustomerPointsDetailByPointsIds(pointsIds));
    }
}
